<?php

namespace App\Models\Content;

use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    use ModelTrait;
    protected $table = 'articles_category';
    protected $fillable = ['sort', 'parent_id', 'name', 'status'];

    public function children()
    {
        return $this->hasMany(self::class, 'parent_id', 'id');
    }

    public function articles()
    {
        return $this->belongsToMany(Article::class, 'articles_has_category', 'category_id', 'article_id');
    }
}
